<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" >
<head>
	<th:block th:include="include :: header('分配套餐选择套餐')" />
	<th:block th:include="include :: bootstrap-editable-css" />
</head>

<body class="gray-bg">
<div class="container-div">
	<div class="row">
		<div class="col-sm-12 search-collapse">
			<form id="role-form">
				<input type="hidden" id="keyIds" name="keyId">
				<div class="select-list">
					<ul>
						<li>
							<label>云厂商：</label>
							<select id="cloudVendor" name="cloudVendor" th:with="type=${@dict.getType('cloud_vendor')}">
								<option value="">所有</option>
								<option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}"></option>
							</select>
						</li>
						<li>
							<a class="btn btn-primary btn-rounded btn-sm" onclick="$.table.search()"><i class="fa fa-search"></i>&nbsp;搜索</a>
							<a class="btn btn-warning btn-rounded btn-sm" onclick="$.form.reset()"><i class="fa fa-refresh"></i>&nbsp;重置</a>
						</li>
					</ul>
				</div>
			</form>
		</div>

		<div class="col-sm-12 select-table table-bordered">
			<table id="bootstrap-table"></table>
		</div>
	</div>
</div>
<th:block th:include="include :: footer" />
<th:block th:include="include :: bootstrap-table-editable-js" />
<script th:inline="javascript">
	var cloudVendorDatas = [[${@dict.getType('cloud_vendor')}]];
	var prefix = ctx + "SSL/cloudKeySecret";

	$(function() {
		$("#cloudVendor").val([[${cloudVendor}]]);
		var options = {
			url: prefix + "/list",
			createUrl: prefix + "/add",
			updateUrl: prefix + "/edit/{id}",
			removeUrl: prefix + "/remove",
			exportUrl: prefix + "/export",
			modalName: "云厂商key管理",
			onEditableSave: onEditableSave,
			columns: [{
				field: 'state',
				radio: true
			},
				{
					field: 'id',
					title: 'Id',
					visible: false
				},
				{
					field: 'cloudVendor',
					title: '云厂商',
					formatter: function(value, row, index) {
						return $.table.selectDictLabel(cloudVendorDatas, value);
					}
				},
				{
					field: 'accessKeyId',
					title: 'keyId',
					formatter:function (value, row, index){
						return $.table.tooltip(value);
					}
				},
				{
					field: 'accessKeySecret',
					title: 'keySecret',
					formatter:function (value, row, index){
						return $.table.tooltip(value);
					}
				},
				{
					field : 'remark',
					title : '备注',
					editable : {
						type : 'text',
						title : '备注',
						emptytext : "【备注】为空",
						validate : function(value) {
							if (value.length == 0) {
								return '名称不能为空';
							}
						}
					}
				},]
		};
		$.table.init(options);
	});
	function onEditableSave (field, row, rowIndex, oldValue, $el) {
		$.operate.post(prefix + "/edit", {id:row.id, remark: row[field]});
	}
	/* 添加用户-选择用户-提交 */
	function submitHandler(index, layero, callback) {
		var rows = $.table.selectFirstColumns();
		if (rows.length == 0) {
			$.modal.alertWarning("请至少选择一条记录");
			return;
		}
		callback(index, rows);
	}
</script>
</body>
</html>
